package com.example.mynewsapp.fragment

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import com.example.mynewsapp.R
import com.example.mynewsapp.adapter.NewsSectionAdapter
import kotlinx.android.synthetic.main.fragment_news.*

class FragmentNews : Fragment() {

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        return inflater.inflate(R.layout.fragment_news, container, false)
    }

    override fun onActivityCreated(savedInstanceState: Bundle?) {
        super.onActivityCreated(savedInstanceState)

        sorts_title.setText(R.string.headline)

        val sectionsPagerAdapter = context?.let { NewsSectionAdapter(it, childFragmentManager) }
        news_view_pager.adapter = sectionsPagerAdapter
        news_tab.setupWithViewPager(news_view_pager)
        news_view_pager.offscreenPageLimit = 1

    }
}